package day4;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Demo5 {

    public static void main(String[] args) {
        HashMap map = new HashMap();
        int[] boll = new int[6];
        int boll2;
        for (int i = 0; i < 6; i++) {
            boll[i] = (int) (Math.random() * 33) + 1;
            while (map.containsKey(boll[i])){
                boll[i] = (int) (Math.random() * 33) + 1;
            }
            map.put(boll[i], i);
        }


        boll2 = (int) (Math.random() * 16);
        while (map.containsKey(boll2)) {
            boll2 = (int) (Math.random() * 16);
        }

        map.put(boll2, 6);


        int[] choose = new int[6];
        int choose2;
        System.out.println("请输入你要兑奖的号码:");
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 6; i++) {
            choose[i] = in.nextInt();
        }

        choose2 = in.nextInt();
        boolean blue = boll2 == choose2;

        int count = 0;
        for (int i : choose) {
            if (map.containsKey(i)) count++;
        }

        if (count == 6 && blue){
            System.out.println("恭喜你中了一等奖");
        } else if (count == 6 && !blue){
            System.out.println("恭喜你中了二等奖");
        } else if (count == 5 && blue){
            System.out.println("恭喜你中了三等奖");
        } else if ((count == 4 && blue) || (count == 5 && !blue)){
            System.out.println("恭喜你中了四等奖");
        } else if ((count == 4 && !blue) || (count == 3 && blue)){
            System.out.println("恭喜你中了五等奖");
        } else if (blue){
            System.out.println("恭喜你中了六等奖");
        } else{
            System.out.println("不中奖，再接再厉");
        }

        System.out.println("中奖号码W为: ");
        for (int i : boll) {
            System.out.print(i + "\t");
        }
        System.out.print(boll2 + "\t");
        System.out.println("你选择的号码为:");
        for (int i : choose) {
            System.out.print(i + "\t");
        }
        System.out.println(choose2 + "\t");
    }

}

